﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MyBBS.Data.Models
{
    public class Post
    {
        public long ID { get; set; }
        public string Title { get; set; }
        public string URL { get; set; }
        public long CategoryID { get; set; }
        public string Description { get; set; }
        public DateTime PostedTime { get; set; }
        public string Tags { get; set; }

        public int KickCount
        {
            get
            {
                return Kicks.Count();
            }
        }

        //Has already been kicked by the current user
        public bool IsKicked { get; set; }
        //TODO: To refactor this with User
        public string Author { get; set; }
        public LazyList<Kick> Kicks { get; set; }
        public LazyList<Comment> Comments { get; set; }

        #region Constructors
        public Post() { }

        public Post(long id, string title, string description, DateTime postedTime, string author, LazyList<Comment> comments)
        {
            this.ID = id;
            this.Title = title;
            this.Description = description;
            this.PostedTime = postedTime;
            this.Author = author;
            this.Comments = comments;
        }
        #endregion

        #region Override
        public override bool Equals(object obj)
        {
            if (obj is Post)
            {
                Post compareTo = (Post)obj;
                return this.ID == compareTo.ID;
            }
            else
                return base.Equals(obj);
        }

        public override int GetHashCode()
        {
            return this.ID.GetHashCode();
        }
        #endregion

    }
}
